{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "24ef578b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "552f5480",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd1 = np.array([[1,2,3],[4,5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3bcbcf09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ec91c862",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "34d7ad91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "48255188",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c49d49cc",
   "metadata": {},
   "outputs": [],
   "source": [
    "b = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "50d8e575",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9812c97a",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd2 = np.array(['1','2','3'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "43b321e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'numpy.ndarray'>\n"
     ]
    }
   ],
   "source": [
    "print(type(nd2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b9ae1b28",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['1', '2', '3'], dtype='<U1')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "498113aa",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "cannot perform reduce with flexible type",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_13188/1778844841.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnd2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmax\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\users\\zzk10\\python37\\lib\\site-packages\\numpy\\core\\_methods.py\u001b[0m in \u001b[0;36m_amax\u001b[1;34m(a, axis, out, keepdims, initial, where)\u001b[0m\n\u001b[0;32m     38\u001b[0m def _amax(a, axis=None, out=None, keepdims=False,\n\u001b[0;32m     39\u001b[0m           initial=_NoValue, where=True):\n\u001b[1;32m---> 40\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mumr_maximum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mout\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkeepdims\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minitial\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwhere\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     41\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     42\u001b[0m def _amin(a, axis=None, out=None, keepdims=False,\n",
      "\u001b[1;31mTypeError\u001b[0m: cannot perform reduce with flexible type"
     ]
    }
   ],
   "source": [
    "nd2.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b5465352",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd2 = nd2.astype('int')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b1b61c0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0d211d7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "78e0b399",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "d060aa30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3]])"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1[0:1:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "d06cdf14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 5, 6]])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1[1:2:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "c991af32",
   "metadata": {},
   "outputs": [],
   "source": [
    "list1 = [[1,2,3],[4,5,6]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "6fab0598",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 2, 3]]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list1[0:1:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "6683ccdc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "ef26d4b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list1[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "a51495dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[2, 3],\n",
       "       [5, 6]])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 二维切片\n",
    "nd1[0:2:1,1:3:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "5a2cba50",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd3 = np.array([\n",
    "    [0,1,2,3,4,5],\n",
    "    [10,11,12,13,14,15],\n",
    "    [20,21,22,23,24,25],\n",
    "    [30,31,32,33,34,35],\n",
    "    [40,41,42,43,44,45],\n",
    "    [50,51,52,53,54,55]\n",
    "    \n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "20e6f47d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(6, 6)"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "3bf9397f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  1,  2,  3,  4,  5],\n",
       "       [10, 11, 12, 13, 14, 15],\n",
       "       [20, 21, 22, 23, 24, 25],\n",
       "       [30, 31, 32, 33, 34, 35],\n",
       "       [40, 41, 42, 43, 44, 45],\n",
       "       [50, 51, 52, 53, 54, 55]])"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "0163d90d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 4])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[0,3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "b2ee41f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[44, 45],\n",
       "       [54, 55]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[4:,4:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "093c4fb2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[20, 22, 24],\n",
       "       [40, 42, 44]])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[2::2,::2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "273ace09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2, 12, 22, 32, 42, 52])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[:,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "48cb7366",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1, 12, 23, 34, 45])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[(0,1,2,3,4),(1,2,3,4,5)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "099effd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[30, 32, 35],\n",
       "       [40, 42, 45],\n",
       "       [50, 52, 55]])"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[3:,[0,2,5]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "97316279",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2, 22, 52])"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[[0,2,5],2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "b55e926a",
   "metadata": {},
   "outputs": [],
   "source": [
    "boolNd = np.array([1,0,1,0,0,1],dtype=np.bool_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "fd78503f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2, 22, 52])"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[boolNd,2] # bool索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "d374ab7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ True, False,  True, False, False,  True])"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "boolNd "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "0cc11a74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  1,  2,  3,  4,  5],\n",
       "       [10, 11, 12, 13, 14, 15],\n",
       "       [20, 21, 22, 23, 24, 25],\n",
       "       [30, 31, 32, 33, 34, 35],\n",
       "       [40, 41, 42, 43, 44, 45],\n",
       "       [50, 51, 52, 53, 54, 55]])"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "e2f223b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False, False, False, False, False],\n",
       "       [False, False, False, False, False, False],\n",
       "       [False, False, False,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True],\n",
       "       [ True,  True,  True,  True,  True,  True]])"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3>22 # 布尔矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "4aa231dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([23, 24, 25, 30, 31, 32, 33, 34, 35, 40, 41, 42, 43, 44, 45, 50, 51,\n",
       "       52, 53, 54, 55])"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[nd3>22]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "a4d8c931",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([23, 25, 31, 33, 35, 41, 43, 45, 51, 53, 55])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[(nd3 % 2 == 1) & (nd3>22)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "c229dd35",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd5 = np.array([[1,2,3],[4,5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "89e93d1e",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd6 = np.array([[2,3,4],[5,6,7]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "62ad814f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "d299078d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[2, 3, 4],\n",
       "       [5, 6, 7]])"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "e7834b1f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 3,  5,  7],\n",
       "       [ 9, 11, 13]])"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5 + nd6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "39dd9f8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-1, -1, -1],\n",
       "       [-1, -1, -1]])"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5 - nd6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "ea4dc4d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2,  6, 12],\n",
       "       [20, 30, 42]])"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5 * nd6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "8467080d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.5       , 0.66666667, 0.75      ],\n",
       "       [0.8       , 0.83333333, 0.85714286]])"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5 / nd6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "44ffd0aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd7 = np.array([[1,2],[2,1],[1,1]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "11026017",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 8,  7],\n",
       "       [20, 19]])"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5.dot(nd7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "5872fa9c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "726e6471",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2],\n",
       "       [2, 1],\n",
       "       [1, 1]])"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "6a69c50e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 9, 12, 15],\n",
       "       [ 6,  9, 12],\n",
       "       [ 5,  7,  9]])"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd7.dot(nd5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "ef903b4f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1. , 0.5],\n",
       "       [0.5, 1. ],\n",
       "       [1. , 1. ]])"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1/nd7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "18f52a22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 5. ,  5.5],\n",
       "       [12.5, 13. ]])"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd5.dot(1/nd7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "ff884698",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.84147098, 0.90929743],\n",
       "       [0.90929743, 0.84147098],\n",
       "       [0.84147098, 0.84147098]])"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sin(nd7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "075b7e38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.median(nd7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "2c950818",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "2c208cb6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.384077491505982"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "d8035acb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "433de319",
   "metadata": {},
   "outputs": [],
   "source": [
    "from numpy import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "ee205138",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.23583975, 0.72918025, 0.02160125, 0.55669153, 0.40060967,\n",
       "        0.23043383, 0.85165943, 0.20501705],\n",
       "       [0.26501001, 0.01653277, 0.05118502, 0.46618943, 0.99230176,\n",
       "        0.70961578, 0.56517019, 0.89488651],\n",
       "       [0.51918515, 0.52606408, 0.49498501, 0.36796194, 0.2142884 ,\n",
       "        0.02081438, 0.58977352, 0.50589253],\n",
       "       [0.62489894, 0.81397172, 0.76882861, 0.45875291, 0.58592909,\n",
       "        0.99869108, 0.1719643 , 0.91736664]])"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.rand(4,8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9596536e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
